<?
    /* -*- Mode: PHP5; tab-width: 4; indent-tabs-mode: nil; basic-offset: 4 -*- */

    /*********************************************************
    *            --== itellico Net Architect ==--
    *
    * @author Kulikov Alexey <a.kulikov@gmail.com>
    * @version n/a
    * @since 23.09.2005
    * @copyright itellico.com 2005
    *
    *********************************************************/
    
    /***
    * Class clientNodeIsearch
    ****
    * This classs represents a folder for quick ads
    ****
    * @package clientNodes
    * @author A Kulikov <a.kulikov@gmail.com>
    * @version n/a
    * @since 23.09.2005
    * @copyright itellico.com 2005
    ***/
    class clientNodeIsearch extends clientNode{
        private $iseachPageType;
        
        /**
         * Process inputs
         * 
         * @return void 
         **/
        public function process(){
            
            //first figure out the ID of the datatype responsible for subitems
            $this->setSearchItemsPageType();
            
            //get folder properties if any
            $data = $this->db->getRow("SELECT * FROM node_inserat_folder WHERE id = ".$this->object);
            $data['title'] = $this->db->getOne("SELECT title FROM objectmap WHERE nodeid = ".$this->node);
            
            //assign all this stuff to smarty
            $this->smarty->assign(array(
                                    'searchItems' => $this->db->getAll("SELECT title, get_path(nodeid)||pageurl||'.html' AS url FROM pagemap WHERE wf_state = 1 AND nodeid = ".$this->node),
                                    'data'        => $data));
        }
        
        /**
         * set the action template to page.html
         * 
         * @return void
         **/
        public function setTemplate(){
            $this->setActionTemplate('inseratSearch.html');
        }
        
        
        /**
         * Sets the ID of the pagetype corresponsing to an inserat
         *
         */
        private function setSearchItemsPageType(){
            $this->iseachPageType = (int)$this->db->getOne("SELECT id FROM datatype WHERE codeset = 'isearchitem'");
            if($this->iseachPageType == 0){
                throw new Exception("No Popular Search Items Datatype Registered with the system!");   
            }
        }
    }
?>